package Controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Bean.Users_Bean;
import Model.ServiceFactory;
import myUtils.MyUtilss;

public class QueryInfoServlet extends HttpServlet{

	private static final long serialVersionUID = 1L;
	
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		//1.获取表单信息
		//2.填充信息到实体类
		Users_Bean usersB=(Users_Bean)MyUtilss.getNewInstance(Users_Bean.class);
		usersB.setUser_id(MyUtilss.objToint(request.getParameter("txtUserId")));//用户id使用隐藏控件连接，使用其JSP控件的id属性值
		usersB.setUser_name(request.getParameter("txtNamee"));
		usersB.setUser_sex(request.getParameter("chSexx"));
		usersB.setUser_age(MyUtilss.objToint(request.getParameter("txtAgee")));//年龄的实体类属性为int，需要转换
		usersB.setUser_age2(MyUtilss.objToint(request.getParameter("txtAgee2")));
		usersB.setUser_tel(request.getParameter("txtPhoo"));
		usersB.setUser_address(request.getParameter("txtAddrr"));
		//3.转到M层进行业务处理
		List lstUse=ServiceFactory.getUseInfoManagerServiceInstance().doQueryByParams(usersB);
		//4.到V层显示处理结果--页面跳转
		if(lstUse!=null && lstUse.size()>0){
			//查询操作
			//将需要显示的结果放入session缓存中
			request.getSession().setAttribute("uuu", lstUse);
			//跳转到结果显示页面
			request.getRequestDispatcher("Logined/user/QueryInforDetails.jsp").forward(request,response);
		}else{
			//显示错误信息提示
			response.sendRedirect("Logined/Error.jsp");
		}
	}
    
	public void destroy() {
		// 
	}

}
